Skip to content

fix(start): preflight agent launch setup#67

Merged
michiosw merged 1 commit intomainfrom
feat/cli-agent-preflight
Apr 18, 2026
Merged

fix(start): preflight agent launch setup#67
michiosw merged 1 commit intomainfrom
feat/cli-agent-preflight

Conversation

@michiosw
Copy link
Copy Markdown
Contributor

@michiosw michiosw commented Apr 16, 2026

Summary

  • Preflights the requested agent before auth, backend session creation, provider sync, or hosted connect.
  • Distinguishes unsupported agents, missing binaries, non-executable binaries, and agent process exits after setup.
  • Keeps downstream agent failures visible instead of silently forwarding only the exit code.

Why

If Claude is missing or cannot run, the CLI should say that before doing any auth or provider work. Developers get a faster failure and avoid creating managed sessions for a launch that was never possible.

Before / After Terminal Capture

Before, setup could run before discovering Claude was unavailable or invalid:

✓ Authenticated as dev@example.com
✓ Session: MacBookPro - kontext-cli (73ec64f7)
Resolving credentials...
Launching claude...
Error: agent "claude" not found in PATH: executable file not found

After, agent setup fails immediately:

Error: agent "claude" not found in PATH

For an agent that launches and exits early, the user gets Kontext context:

Launching claude...
Error: claude exited with code 1 after Kontext setup completed
✓ Session ended (73ec64f7)

Verification

  • Ran go test ./... on this branch.

Copy link
Copy Markdown
Contributor Author

michiosw commented Apr 16, 2026

devin-ai-integration[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@michiosw michiosw force-pushed the feat/cli-agent-preflight branch from 81dc3e6 to 97d7ef9 Compare April 17, 2026 07:02
@michiosw michiosw force-pushed the feat/cli-auth-identity branch from 5f60603 to 6010307 Compare April 17, 2026 07:02
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@michiosw michiosw requested a review from tumberger April 17, 2026 07:08
@michiosw michiosw force-pushed the feat/cli-agent-preflight branch from 97d7ef9 to af1783e Compare April 17, 2026 07:12
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@michiosw michiosw force-pushed the feat/cli-agent-preflight branch from af1783e to abc4ea2 Compare April 17, 2026 07:22
tumberger
tumberger previously approved these changes Apr 17, 2026
Copy link
Copy Markdown
Contributor

@tumberger tumberger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link
Copy Markdown
Contributor Author

michiosw commented Apr 18, 2026

Merge activity

  • Apr 18, 12:43 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Apr 18, 12:44 PM UTC: Graphite rebased this pull request as part of a merge.
  • Apr 18, 12:46 PM UTC: @michiosw merged this pull request with Graphite.

@michiosw michiosw changed the base branch from feat/cli-auth-identity to graphite-base/67 April 18, 2026 12:43
@michiosw michiosw changed the base branch from graphite-base/67 to main April 18, 2026 12:43
@michiosw michiosw dismissed tumberger’s stale review April 18, 2026 12:43

The base branch was changed.

@michiosw michiosw force-pushed the feat/cli-agent-preflight branch from abc4ea2 to 9b1d31c Compare April 18, 2026 12:44
@michiosw michiosw merged commit c40cbeb into main Apr 18, 2026
4 of 5 checks passed
@michiosw michiosw deleted the feat/cli-agent-preflight branch April 18, 2026 12:46
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9b1d31cb67

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/run/run.go
func Start(ctx context.Context, opts Options) error {
if _, ok := agent.Get(opts.Agent); !ok {
return fmt.Errorf("unsupported agent %q (supported: %s)", opts.Agent, strings.Join(supportedAgents(), ", "))
agentPath, err := preflightAgent(opts.Agent)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Re-resolve the agent binary right before launch

Start caches agentPath before auth/session/bootstrap and then executes that same path much later, so a binary swap/removal during setup (for example, an auto-update or any writable PATH directory) can still cause a late failure or execute a different file than the one originally preflighted. This weakens the stated preflight guarantee because launchability is no longer checked at the point of exec.Command; re-validating the path immediately before launch would avoid this long TOCTOU window.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants